#ifndef HTTP_LIB_SRV_H_
#define HTTP_LIB_SRV_H_

#include "httplib.h"
#include "common.h"
#include "json.h"
#include <atomic>


using json = nlohmann::json;

class HttpLibSrv
{
public:
    HttpLibSrv(std::string ip_address = "localhost", int port = 8052)
        : ip_address_(ip_address), port_(port)
    {

        initial();
        bool status = svr.listen(ip_address_, port_);
        if (!status)
        {
            printf("server failed to start...\n");
        }
    };
    ~HttpLibSrv(){

    };

private:
    httplib::Server svr;
    std::string ip_address_;
    int port_;
    std::vector<bool> is_valid;

    void initial();
};

void HttpLibSrv::initial()
{
    svr.Get("/hi", [](const httplib::Request &, httplib::Response &res)
            { res.set_content("Hello World!", "text/plain"); });
}

#endif /* HTTP_LIB_SRV_H_ */